package com.tulingxueyuan.mall.controller;

import com.tulingxueyuan.mall.common.api.CommonResult;
import com.tulingxueyuan.mall.dto.HomeGoodsSaleDto;
import com.tulingxueyuan.mall.dto.HomeMenusBannerDto;
import com.tulingxueyuan.mall.dto.HomeMenusDto;
import com.tulingxueyuan.mall.modules.pms.service.PmsProductCategoryService;
import com.tulingxueyuan.mall.modules.sms.model.SmsHomeAdvertise;
import com.tulingxueyuan.mall.modules.sms.service.SmsHomeAdvertiseService;
import com.tulingxueyuan.mall.modules.sms.service.SmsHomeCategoryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/home")
@Api(tags = "HomeController",description = "首页内容管理")
public class HomeController {
    @Autowired
    PmsProductCategoryService pmsProductCategoryService;
    @Autowired
    SmsHomeAdvertiseService smsHomeAdvertiseService;
    @Autowired
    SmsHomeCategoryService homeCategoryService;
    @GetMapping("/menus_banner")
    public CommonResult getMenus(){
//        查的是导航
       List<HomeMenusDto> homeMenusDtoList = pmsProductCategoryService.getMenus();
//       查的是banner
        List<SmsHomeAdvertise> smsHomeAdvertises = smsHomeAdvertiseService.getBanner();
        HomeMenusBannerDto homeMenusBannerDto = new HomeMenusBannerDto();
//        BeanUtils.copyProperties(homeMenusDtoList,homeMenusBannerDto);
        homeMenusBannerDto.setHomeMenusDtoList(homeMenusDtoList);
        homeMenusBannerDto.setHomeAdvertiseList(smsHomeAdvertises);
        return CommonResult.success(homeMenusBannerDto);
    }

    /**
     *
     */
    @GetMapping("/goods_sale")
    public CommonResult getGoodsSale(){
       List<HomeGoodsSaleDto> homeGoodsSaleDtos =homeCategoryService.getGoodsSale();
       return CommonResult.success(homeGoodsSaleDtos);
    }
}
